const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin")
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
const { VueLoaderPlugin } = require('vue-loader')
module.exports = {
    entry: path.join(__dirname, 'src/main.js'),
    output: {
        filename: 'bundle.js',
        path: path.join(__dirname, 'dist')
    },
    module: {
        rules: [
            { test: /\.css/, use: ["style-loader", "css-loader"] },
            {
                test: /\.(png|jpg|gif|svg|jpeg)$/i,
                use: [
                    {
                        loader: "url-loader",
                        options: {
                            limit: 1024
                        }
                    }
                ]
            },
            {
                test: /\.vue$/,
                loader: 'vue-loader'
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin(
            {
                //以哪个文件为模板
                template: path.join(__dirname, 'public/index.html'),
                //文件名
                filename: 'index.html'
            }
        ),
        new CleanWebpackPlugin(),
        new VueLoaderPlugin()
    ],
    devServer: {
        static: {
            directory: path.join(__dirname, 'public'),
        },
        port: 8080,
        compress: true,
        client: {
            overlay: true          // 将报错显示在页面上
        },
        
    },
    devtool: "inline-source-map",//错误追踪
    mode: "development"
}